package com.ruoyi.web.controller.kiku;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.kiku.domain.KikuLike;
import com.ruoyi.kiku.service.IKikuLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 小鞠喜欢事物Controller
 *
 * @author TT
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/kiku/like")
public class KikuLikeController extends BaseController
{
    @Autowired
    private IKikuLikeService kikuLikeService;

    /**
     * 查询小鞠喜欢事物列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:like:list')")
    @GetMapping("/list")
    public TableDataInfo list(KikuLike kikuLike)
    {
        startPage();
        List<KikuLike> list = kikuLikeService.selectKikuLikeList(kikuLike);
        return getDataTable(list);
    }

    /**
     * 导出小鞠喜欢事物列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:like:export')")
    @Log(title = "小鞠喜欢事物", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KikuLike kikuLike)
    {
        List<KikuLike> list = kikuLikeService.selectKikuLikeList(kikuLike);
        ExcelUtil<KikuLike> util = new ExcelUtil<KikuLike>(KikuLike.class);
        util.exportExcel(response, list, "小鞠喜欢事物数据");
    }

    /**
     * 获取小鞠喜欢事物详细信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:like:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kikuLikeService.selectKikuLikeById(id));
    }

    /**
     * 新增小鞠喜欢事物
     */
    @PreAuthorize("@ss.hasPermi('kiku:like:add')")
    @Log(title = "小鞠喜欢事物", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KikuLike kikuLike)
    {
        return toAjax(kikuLikeService.insertKikuLike(kikuLike));
    }

    /**
     * 修改小鞠喜欢事物
     */
    @PreAuthorize("@ss.hasPermi('kiku:like:edit')")
    @Log(title = "小鞠喜欢事物", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KikuLike kikuLike)
    {
        return toAjax(kikuLikeService.updateKikuLike(kikuLike));
    }

    /**
     * 删除小鞠喜欢事物
     */
    @PreAuthorize("@ss.hasPermi('kiku:like:remove')")
    @Log(title = "小鞠喜欢事物", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kikuLikeService.deleteKikuLikeByIds(ids));
    }
}
